// 用户管理相关接口
import request from '@/utils/request'

import type {
  IUserQueryData,
  IUserListResponseData,
  IUserFormData,
} from './type'
import type { ResponseData } from '@/types/common'

enum API {
  USER_LIST_URL = '/admin/acl/user',
  USER_ADD_URL = '/admin/acl/user/save',
  USER_EDIT_URL = '/admin/acl/user/update',
  USER_DEL_URL = '/admin/acl/user/remove',
}

// 用户信息列表接口
export const reqUserList = (data: IUserQueryData) => {
  const { page, limit, username, name } = data
  const url = API.USER_LIST_URL + `/${page}/${limit}`
  const params = {
    username,
    name,
  }
  return request.get<any, IUserListResponseData>(url, { params })
}

// 新增用户接口
export const reqUserAdd = (data: IUserFormData) => {
  return request.post<any, ResponseData>(API.USER_ADD_URL, data)
}

// 修改用户接口
export const reqUserEdit = (data: IUserFormData) => {
  return request.put<any, ResponseData>(API.USER_EDIT_URL, data)
}

// 删除用户接口
export const reqUserDel = (id: number) => {
  return request.delete<any, ResponseData>(API.USER_DEL_URL + `/${id}`)
}
